import java.util.Arrays;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: hp
 * Date: 2024-03-07
 * Time: 14:01
 */
class Student implements Comparable<Student>{
    public String name;
    public int age;
    public Student(String name, int age) {
        this.name = name;
        this.age = age;
    }
    @Override
    public int compareTo(Student o) {
        return this.age - o.age;
    }
    @Override
    public String toString() {
        return "Student{" +
                "name='" + name + '\'' +
                ", age=" + age +
                '}';
    }

}

public class Test1 {
    public static void main(String[] args) {
        Student[] students= new Student[3];
       students[0] = new Student("小明",11);
        students[1] = new Student("小宏",12);
        students[2] = new Student("小huang",13);
        System.out.println(Arrays.toString(students));
        Arrays.sort(students);
        System.out.println(Arrays.toString(students));

    }

 /*   public static void main2(String[] args) {
        String str1 = "abcd";
        String str2 = "ljbf";
        if(str1.compareTo(str2) > 0) {
            System.out.println("str1 > str2");
        }
        else if(str1.compareTo(str2) == 0) {
            System.out.println("str1 = str2");
        }
        else {
            System.out.println("str1 < str2");
        }
    }
    public static void main1(String[] args) {
        Student student1 = new Student("小明",11);
        Student student2 = new Student("小宏",12);
        if(student1.compareTo(student2) > 0) {
            System.out.println("student1 > student2");
        }
        else {
            System.out.println("student1 <=student2");
        }
    }*/


}
